using System.Collections.Generic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    /// <summary>
    /// 地图主界面可能同时加载多张地图
    /// 没有Container的地图会被释放
    /// 构建一个临时Container存放这些地图以避免反复加载
    /// </summary>
    public class UIN_LevelMapTempContainer : IMapContainer
    {
        public UIN_LevelMapTempContainer(RectTransform rt)
        {
            containerRT = rt;
            _tempMaps = new List<UIMapRoot>();
        }
        
        public RectTransform containerRT { get;}

        public void OnMapAttach(UIMapRoot mapRoot)
        {
            _tempMaps.Add(mapRoot);
        }

        public void OnMapDetach()
        {
        }

        public bool FilterMapSymbol(IMapSymbolData data)
        {
            return true;
        }

        public void HandleSymbolInteract(IMapSymbolData data) { }
        public float radius => 0;

        public void Clear()
        {
            foreach (var map in _tempMaps)
            {
                map.DetachFrom(this);
            }
        }

        private readonly List<UIMapRoot> _tempMaps;
    }
}